/**
 * Created by Administrator on 2017/7/12.
 */
var i = -1;
var toastCount = 0;
var $toastlast;
/*
 $(function () {
 $('#showtoast').click(function () {

 var shortCutFunction = $("#toastTypeGroup input:radio:checked").val();

 var msg = $('#message').val();

 var title = $('#title').val() || '';

 var $showDuration = $('#showDuration');

 var $hideDuration = $('#hideDuration');

 var $timeOut = $('#timeOut');

 var $extendedTimeOut = $('#extendedTimeOut');

 var $showEasing = $('#showEasing');

 var $hideEasing = $('#hideEasing');

 var $showMethod = $('#showMethod');

 var $hideMethod = $('#hideMethod');

 var toastIndex = toastCount++;



 toastr.options = {

 closeButton: $('#closeButton').prop('checked'),

 debug: $('#debugInfo').prop('checked'),

 positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right',

 onclick: null

 };



 if ($('#addBehaviorOnToastClick').prop('checked')) {

 toastr.options.onclick = function () {

 alert('You can perform some custom action after a toast goes away');

 };

 }



 if ($showDuration.val().length) {

 toastr.options.showDuration = $showDuration.val();

 }



 if ($hideDuration.val().length) {

 toastr.options.hideDuration = $hideDuration.val();

 }



 if ($timeOut.val().length) {

 toastr.options.timeOut = $timeOut.val();

 }



 if ($extendedTimeOut.val().length) {

 toastr.options.extendedTimeOut = $extendedTimeOut.val();

 }



 if ($showEasing.val().length) {

 toastr.options.showEasing = $showEasing.val();

 }



 if ($hideEasing.val().length) {

 toastr.options.hideEasing = $hideEasing.val();

 }



 if ($showMethod.val().length) {

 toastr.options.showMethod = $showMethod.val();

 }



 if ($hideMethod.val().length) {

 toastr.options.hideMethod = $hideMethod.val();

 }


 $("#toastrOptions").text("Command: toastr["

 + shortCutFunction

 + "](\""

 + msg

 + (title ? "\", \"" + title : '')

 + "\")\n\ntoastr.options = "

 + JSON.stringify(toastr.options, null, 2)

 );



 var $toast = toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists

 $toastlast = $toast;

 if ($toast.find('#okBtn').length) {

 $toast.delegate('#okBtn', 'click', function () {

 alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');

 $toast.remove();

 });

 }

 if ($toast.find('#surpriseBtn').length) {

 $toast.delegate('#surpriseBtn', 'click', function () {

 alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');

 });

 }

 });
 function getLastToast(){

 return $toastlast;

 }
 $('#clearlasttoast').click(function () {

 toastr.clear(getLastToast());

 });
 $('#cleartoasts').click(function () {

 toastr.clear();

 });
 })
 */
var msgfun = {
    showMsg: function (msgTyp,title,msg) {
        //msgTyp有以下4种类型
        // success    info    warning   error
        var msgTypVal = 'success';
        switch (msgTyp){

            case 1:
                msgTypVal = 'success';
                break;
            case 2:
                msgTypVal = 'info';
                break;
            case 3:
                msgTypVal = 'warning';
                break;
            case 4:
                msgTypVal = 'error';
                break;
            default:
                msgTypVal = 'success';
                break;
        }

        var positionClass = 'toast-top-full-width';
        var toastIndex = toastCount++;

        /* 以下是消息显示位置，后期可根据需求再调整
         toast-top-right
         toast-bottom-right
         toast-bottom-left
         toast-top-left
         toast-top-full-width
         toast-bottom-full-width
         */
        toastr.options = {
            closeButton: false,
            debug: false,
            positionClass:positionClass,
            onclick: null
        };
        //可以传一个参数过来，控制点击消息体，执行动作。
        //if (xxxx) {
        //    toastr.options.onclick = function () {
        //        alert('You can perform some custom action after a toast goes away');
        //    };
        //}
        toastr.options.showDuration = "300";
        toastr.options.hideDuration = "1000";
        toastr.options.timeOut = "3000";
        toastr.options.extendedTimeOut = "1000";
        toastr.options.showEasing = "swing";
        toastr.options.hideEasing = "linear";
        toastr.options.showMethod = "fadeIn";
        toastr.options.hideMethod = "fadeOut";

        $("#toastrOptions").text("Command: toastr["
            + msgTypVal
            + "](\""
            + msg
            + (title ? "\", \"" + title : '')
            + "\")\n\ntoastr.options = "
            + JSON.stringify(toastr.options, null, 2)
        );

        var $toast = toastr[msgTypVal](msg, title); // Wire up an event handler to a button in the toast, if it exists

        $toastlast = $toast;

        if ($toast.find('#okBtn').length) {
            $toast.delegate('#okBtn', 'click', function () {
                alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');
                $toast.remove();
            });
        }

        if ($toast.find('#surpriseBtn').length) {
            $toast.delegate('#surpriseBtn', 'click', function () {
                alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');
            });
        }
    },
    clearlasttoast:function(){

    }
}
